<html>
<head><meta charset="utf-8"><title>future-not-send diagnostic #64130 · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html">future-not-send diagnostic #64130</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="175358491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175358491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175358491">(Sep 10 2019 at 17:21)</a>:</h4>
<p>I'm going to dump some thoughts here to start. <span class="user-mention" data-user-id="119031">@Esteban Küber</span> I'd love your feedback, too</p>



<a name="175358564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175358564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175358564">(Sep 10 2019 at 17:21)</a>:</h4>
<p>First off, I think the ideal would be if we could figure out, when looking at a causal chain that derives from a generator or closure in the current crate, that we want to somehow cite the local variable that gave rise to that field.</p>



<a name="175358827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175358827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175358827">(Sep 10 2019 at 17:24)</a>:</h4>
<p>I'm imagining</p>
<div class="codehilite"><pre><span></span>error[E0277]: `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
  --&gt; src/main.rs:23:5
   |
23 |     is_send(foo());
   |     ^^^^^^^ `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
   |
note: the `MutexGuard` is captured by the future representing the function `foo`:
   | async fn foo() {
xx |     bar(&amp;Mutex::new(22)).await;
   |            ------------ the result of this expression is potentially live across an await
   | }
</pre></div>



<a name="175358855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175358855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175358855">(Sep 10 2019 at 17:24)</a>:</h4>
<p>this seems like something we could pretty readily do by examining the causal chain; when we see that one of the types is a field of a generator, we can find the def-id of that generator</p>



<a name="175358876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175358876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175358876">(Sep 10 2019 at 17:24)</a>:</h4>
<p>we can figure out what expression the field represents (I have to check on how to do <em>that</em>)</p>



<a name="175358881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175358881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175358881">(Sep 10 2019 at 17:25)</a>:</h4>
<p>and that kind of gives us everything we want to know</p>



<a name="175358901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175358901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175358901">(Sep 10 2019 at 17:25)</a>:</h4>
<p>it won't work for futures defined in other crates, but let's define our scope apropriately</p>



<a name="175359076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175359076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175359076">(Sep 10 2019 at 17:25)</a>:</h4>
<p>(in that case, we could write something like "captured by the future respresenting <code>other_crate::foo::bar</code>, at least)</p>



<a name="175359115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175359115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175359115">(Sep 10 2019 at 17:25)</a>:</h4>
<p>one question would be whether it's important to show how the <em>future type</em> is reachable from the actual type, but I think that's less vital</p>



<a name="175844553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175844553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175844553">(Sep 16 2019 at 19:33)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="119031">@Esteban Küber</span> -- you around by any chance?</p>



<a name="175845148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175845148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175845148">(Sep 16 2019 at 19:40)</a>:</h4>
<p>What's up</p>



<a name="175845670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175845670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175845670">(Sep 16 2019 at 19:46)</a>:</h4>
<p>I was looking into what this message should say and wanted to bounce it off somebody</p>



<a name="175845822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175845822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175845822">(Sep 16 2019 at 19:48)</a>:</h4>
<p>I feel like it should .. walk you through the call stack?</p>



<a name="175846002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175846002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175846002">(Sep 16 2019 at 19:50)</a>:</h4>
<p>what I had in mind so far</p>



<a name="175846005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175846005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175846005">(Sep 16 2019 at 19:50)</a>:</h4>
<div class="codehilite"><pre><span></span>error[E0277]: `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
  --&gt; src/main.rs:23:5
   |
23 |     is_send(foo());
   |     ^^^^^^^ `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
   |
note: the `MutexGuard` arises from the suspended state from calling `foo`
note: in the function `foo`:
   | async fn foo() {
   |          --- the future that results from calling foo...
NN |     bar(&amp;Mutex::new(22)).await;
   |     --- may suspend while calling bar...
note: in the function `bar`
   | async fn bar() {
   |          --- the future that results from calling bar...
NN |     let g = x.lock().unwrap();
   |         - may suspend with `g`, a `MutexGuard` on the stack
</pre></div>



<a name="175846012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175846012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175846012">(Sep 16 2019 at 19:50)</a>:</h4>
<p>something like that?</p>



<a name="175846023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175846023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175846023">(Sep 16 2019 at 19:50)</a>:</h4>
<p>kind of busy</p>



<a name="175846059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175846059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175846059">(Sep 16 2019 at 19:51)</a>:</h4>
<p>also, it doesn't say <em>where</em> the original <code>Send</code> requirement comes from</p>



<a name="175855686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855686">(Sep 16 2019 at 21:45)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> as is the output you're mocking can't be done</p>



<a name="175855695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855695">(Sep 16 2019 at 21:45)</a>:</h4>
<p>we can't have multiple spans in a note :-/</p>



<a name="175855724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855724">(Sep 16 2019 at 21:45)</a>:</h4>
<p>I'm thinking using secondary spans directly would be better for communication:</p>



<a name="175855742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855742">(Sep 16 2019 at 21:45)</a>:</h4>
<blockquote>
<p>we can't have multiple spans in a note :-/</p>
</blockquote>
<p>we should fix that</p>



<a name="175855802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855802">(Sep 16 2019 at 21:46)</a>:</h4>
<p>but I don't know that the "primary span" is important here anyway</p>



<a name="175855810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855810">(Sep 16 2019 at 21:46)</a>:</h4>
<p>er, the underlining of <code>foo</code></p>



<a name="175855823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855823">(Sep 16 2019 at 21:46)</a>:</h4>
<p>I believe we have a ticket for it, but we haven't worked on it due to the <code>annotate-snippets</code> epic</p>



<a name="175855830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855830">(Sep 16 2019 at 21:46)</a>:</h4>
<p>can you paste the original code?</p>



<a name="175855851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855851">(Sep 16 2019 at 21:46)</a>:</h4>
<p>yeah I mean we should fix it by adopting a more general model from which it just falls out</p>



<a name="175855856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855856">(Sep 16 2019 at 21:46)</a>:</h4>
<p>I wan to mock my preferred output with the right code</p>



<a name="175855872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855872">(Sep 16 2019 at 21:47)</a>:</h4>
<p>code is in <a href="https://github.com/rust-lang/rust/issues/64130" target="_blank" title="https://github.com/rust-lang/rust/issues/64130">#64130</a></p>



<a name="175855875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855875">(Sep 16 2019 at 21:47)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">use</span><span class="w"> </span><span class="n">std</span>::<span class="n">sync</span>::<span class="n">Mutex</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">is_send</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Send</span><span class="o">&gt;</span><span class="p">(</span><span class="n">t</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>

<span class="p">}</span><span class="w"></span>

<span class="n">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="n">bar</span><span class="p">(</span><span class="o">&amp;</span><span class="n">Mutex</span>::<span class="n">new</span><span class="p">(</span><span class="mi">22</span><span class="p">)).</span><span class="n">await</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="n">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">Mutex</span><span class="o">&lt;</span><span class="kt">u32</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">g</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="n">lock</span><span class="p">().</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="w">  </span><span class="n">baz</span><span class="p">().</span><span class="n">await</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="n">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">baz</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>

<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">is_send</span><span class="p">(</span><span class="n">foo</span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="175855883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855883">(Sep 16 2019 at 21:47)</a>:</h4>
<p>gotta run right now</p>



<a name="175855887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855887">(Sep 16 2019 at 21:47)</a>:</h4>
<p>but I'll check back in later</p>



<a name="175855915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175855915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175855915">(Sep 16 2019 at 21:47)</a>:</h4>
<p>separately, I was chatting about it with wycats, who thought that I was overemphasizing the concept of "suspended state", but we didnt' get a chance to dig into what could replace that</p>



<a name="175856188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175856188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175856188">(Sep 16 2019 at 21:50)</a>:</h4>
<p>I'm thinking something like</p>
<div class="codehilite"><pre><span></span>error[E0277]: `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
  --&gt; src/main.rs:23:5
   |
LL | async fn foo() {
   |          --- when calling this fn resolving in a future...
LL |     bar(&amp;Mutex::new(22)).await;
   |     --- ...this might suspend
...
   | async fn bar() {
   |          --- when calling this fn resolving in a future...
LL |     let g = x.lock().unwrap();
   |         - may suspend with `g`, a `MutexGuard` on the stack (improve wording)
...
LL |     is_send(foo());
   |     ^^^^^^^ `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
</pre></div>



<a name="175856233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175856233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175856233">(Sep 16 2019 at 21:51)</a>:</h4>
<p>but even it is not ideal...</p>



<a name="175927491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/175927491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Giles Cope <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#175927491">(Sep 17 2019 at 17:15)</a>:</h4>
<p>As a nubie reading this, the point is coming across, though I spent a lot of time parsing " when calling this fn resolving in a future..."<br>
How about:</p>
<p>let g = x.lock().unwrap();<br>
   - may suspend with <code>g</code> on the stack as it's in an async context, but alas <code>MutexGuard</code> is not <code>Send</code>.</p>
<p>and ditch the preamble of "--- when calling this fn resolving in a future..."? (Sorry for unasked bikeshedding)</p>



<a name="176046562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176046562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176046562">(Sep 18 2019 at 21:05)</a>:</h4>
<p>I'm dubious <span class="user-mention" data-user-id="119031">@Esteban Küber</span> about avoiding notes, because I think the order in which things show up may be confusing.</p>



<a name="176046582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176046582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176046582">(Sep 18 2019 at 21:05)</a>:</h4>
<p>This reminds me of my ideas to extend the diagnostic API with some way to say "this really has to be shown first", which could take advantage of source order when it fits...but otherwise change how we show things.</p>



<a name="176046674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176046674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176046674">(Sep 18 2019 at 21:06)</a>:</h4>
<p>Anyway I'm going to leave some notes about what it would take to do anything at all. And we can hammer out the best appearance after</p>



<a name="176048401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176048401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176048401">(Sep 18 2019 at 21:30)</a>:</h4>
<p>OK, <span class="user-mention" data-user-id="116107">@davidtwco</span>, I left some <a href="https://github.com/rust-lang/rust/issues/64130#issuecomment-532874280" target="_blank" title="https://github.com/rust-lang/rust/issues/64130#issuecomment-532874280">high-level notes</a> that sketch out the approach I had in mind. It's a non-trivial task; seems unlikely to get done before beta branches, but could <em>maybe</em> be backported. (I think it would well be worth it.) Even if we don't backport, just having it landed on nightly (and available in next release) seems worth it.</p>
<p>Do you think you're up to try and tackle it? Feel free to say no, I could also take a stab, though I don't know if I'll have time.</p>



<a name="176048713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176048713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176048713">(Sep 18 2019 at 21:34)</a>:</h4>
<p>Thanks. I should have time. I’ll give it a go over the next few days.</p>



<a name="176049588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176049588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176049588">(Sep 18 2019 at 21:46)</a>:</h4>
<p>Awesome! Obviously send any questions my way.</p>



<a name="176050024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176050024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176050024">(Sep 18 2019 at 21:52)</a>:</h4>
<blockquote>
<p>This reminds me of my ideas to extend the diagnostic API with some way to say "this really has to be shown first", which could take advantage of source order when it fits...but otherwise change how we show things.</p>
</blockquote>
<p>I'll try to tackle that once we've moved to <code>annotate-snippets</code> across the board.</p>



<a name="176409455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176409455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176409455">(Sep 23 2019 at 21:03)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> can you clarify something? </p>
<blockquote>
<p>I think what I would like to do is to also remember the hir_id that caused this type to be added. This would probably be stored in the typeck-tables for the generator. Then, when we are printing the stack trace above, and we see an error was reported for some type in the interior, we can find its index and use that to grab the hir_id that caused the type to be added.</p>
</blockquote>
<p>By this, do you mean adding a new field to <code>TypeckTables</code> and storing the <code>HirId</code>s in that?</p>



<a name="176410269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176410269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176410269">(Sep 23 2019 at 21:14)</a>:</h4>
<p>I think that's what I meant, yes.</p>



<a name="176412416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176412416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176412416">(Sep 23 2019 at 21:43)</a>:</h4>
<p>I'm struggling to get the <code>hir_id</code> for the exprs.. I added a field to <code>TypeckTables</code>, and in the <code>record</code> function in <code>generator_interior</code>, I also kept track of the <code>expr.map(|e| e.hir_id)</code>. In <code>resolve_interior</code>, I stored that into <code>visitor.fcx.inh.tables.borrow_mut().&lt;my_field&gt;</code>. But in my error reporting function, if I do <code>tcx.typeck_tables_of(generator_did)</code>, then there's nothing in my field. I suspect this isn't quite what you intended me to be doing.</p>



<a name="176412579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176412579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176412579">(Sep 23 2019 at 21:45)</a>:</h4>
<p>I'm also unclear on this part:</p>
<blockquote>
<p>and we see an error was reported for some type in the interior</p>
</blockquote>
<p>Not sure how to work out which type in the interior had the error and thus, which index I should use to get the <code>HirId</code> (when I have access to them).</p>



<a name="176413023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413023">(Sep 23 2019 at 21:51)</a>:</h4>
<blockquote>
<p>I suspect this isn't quite what you intended me to be doing.</p>
</blockquote>
<p>Hmm, it <em>sounds</em> right, but I suspect some of ... "off by one" thing going on.</p>



<a name="176413254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413254">(Sep 23 2019 at 21:55)</a>:</h4>
<p>Ah, <span class="user-mention" data-user-id="116107">@davidtwco</span> -- perhaps the problem is that you haven't modified the write-back code?</p>



<a name="176413276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413276">(Sep 23 2019 at 21:55)</a>:</h4>
<p>I definitely haven't modified the writeback code, so if that's something I need to be doing, that'll be the issue.</p>



<a name="176413326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413326">(Sep 23 2019 at 21:56)</a>:</h4>
<p>Yeah, so, dear god I don't know if this in the rustc-guide but it should be</p>



<a name="176413333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413333">(Sep 23 2019 at 21:56)</a>:</h4>
<p>anyway so we build up a "temporary" copy of the typeck-tables, which is the one you are modifying</p>



<a name="176413339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413339">(Sep 23 2019 at 21:56)</a>:</h4>
<p>then <a href="https://github.com/rust-lang/rust/blob/66bf391c3aabfc77f5f7139fc9e6944f995d574e/src/librustc_typeck/check/writeback.rs#L60" target="_blank" title="https://github.com/rust-lang/rust/blob/66bf391c3aabfc77f5f7139fc9e6944f995d574e/src/librustc_typeck/check/writeback.rs#L60">around this line</a> we copy from that temporary one to the final one,</p>



<a name="176413344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413344">(Sep 23 2019 at 21:56)</a>:</h4>
<p>resolving type inference variables along the way and other artifacts of type inference</p>



<a name="176413350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413350">(Sep 23 2019 at 21:56)</a>:</h4>
<p>so you'll want to add a line like <a href="https://github.com/rust-lang/rust/blob/66bf391c3aabfc77f5f7139fc9e6944f995d574e/src/librustc_typeck/check/writeback.rs#L60" target="_blank" title="https://github.com/rust-lang/rust/blob/66bf391c3aabfc77f5f7139fc9e6944f995d574e/src/librustc_typeck/check/writeback.rs#L60">that one</a> for your field</p>



<a name="176413378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413378">(Sep 23 2019 at 21:57)</a>:</h4>
<p>(man, I need to start making a little list of like "random things that have to be explained semi-regularly", so we can point to them...)</p>



<a name="176413379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413379">(Sep 23 2019 at 21:57)</a>:</h4>
<p>Thanks, will try that.</p>



<a name="176413386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413386">(Sep 23 2019 at 21:57)</a>:</h4>
<p>great! I gotta run, but bbl</p>



<a name="176413407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413407">(Sep 23 2019 at 21:57)</a>:</h4>
<p>also btw I posted an error message that <span class="user-mention" data-user-id="211722">@Yoshua Wuyts</span> and I came up with --</p>



<a name="176413457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413457">(Sep 23 2019 at 21:58)</a>:</h4>
<p>it's worth mentioning only because it doesn't require gathering the whole 'stack trace' for the diagnostics, just the 'top frame'</p>



<a name="176413459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413459">(Sep 23 2019 at 21:58)</a>:</h4>
<p>but I guess you didn't get that far yet :)</p>



<a name="176413479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176413479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176413479">(Sep 23 2019 at 21:58)</a>:</h4>
<p>I've got the frames (not with actual messages, just spans for the functions) like in your original example, and none of the details inside of the functions yet.</p>



<a name="176417802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176417802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176417802">(Sep 23 2019 at 23:06)</a>:</h4>
<p>Having not seen your newest sketch of what the error message should be until having been going on this for a day or two, this is what I've got tonight before packing it in for the day:</p>
<div class="codehilite"><pre><span></span>error[E0277]: `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
  --&gt; src/test/ui/async-await/issue-64130-non-send-future-diags.rs:23:5
   |
23 |     is_send(foo());
   |     ^^^^^^^ `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
   |
   = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard&lt;&#39;_, u32&gt;`
note: in the suspended state from calling `XXX`
  --&gt; src/test/ui/async-await/issue-64130-non-send-future-diags.rs:9:16
   |
9  |   async fn foo() {
   |  ________________^
10 | |     bar(&amp;Mutex::new(22)).await;
   | |     --- may suspend when calling
11 | | }
   | |_^
note: in the suspended state from calling `XXX`
  --&gt; src/test/ui/async-await/issue-64130-non-send-future-diags.rs:13:30
   |
13 |   async fn bar(x: &amp;Mutex&lt;u32&gt;) {
   |  ______________________________^
14 | |     let g = x.lock().unwrap();
15 | |     baz().await;
   | |     --- may suspend when calling
16 | | }
   | |_^
</pre></div>



<a name="176421886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176421886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176421886">(Sep 24 2019 at 00:28)</a>:</h4>
<p>nice!</p>



<a name="176506841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176506841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176506841">(Sep 24 2019 at 21:12)</a>:</h4>
<p><strong>my error:</strong></p>
<div class="codehilite"><pre><span></span>error[E0277]: `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
  --&gt; src/test/ui/async-await/issue-64130-non-send-future-diags.rs:23:5
   |
23 |     is_send(foo());
   |     ^^^^^^^ `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
   |
   = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard&lt;&#39;_, u32&gt;`
note: in the suspended state from calling `bar`
  --&gt; src/test/ui/async-await/issue-64130-non-send-future-diags.rs:13:1
   |
13 | / async fn bar(x: &amp;Mutex&lt;u32&gt;) {
14 | |     let g = x.lock().unwrap();
15 | |     baz().await;
   | |     --- may suspend when calling
16 | | }
   | |_^
</pre></div>


<p>I'm not sure how to get a smaller span for the function name, or how to get the other parts to point at, like <code>g</code>, or the <code>await</code>. </p>
<p>The generator interior types expression spans are just <code>bar().await</code> and then <code>bar()</code> and <code>await</code> and effectively all of the smaller spans you could get out of that line.</p>
<p>Any ideas <span class="user-mention" data-user-id="116009">@nikomatsakis</span>?</p>



<a name="176506865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176506865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176506865">(Sep 24 2019 at 21:12)</a>:</h4>
<p>Oh, or the span for the <code>T: Send</code> bound on <code>is_send</code>.</p>



<a name="176506930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176506930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176506930">(Sep 24 2019 at 21:13)</a>:</h4>
<p><strong>target error:</strong></p>
<div class="codehilite"><pre><span></span>error[E0277]: future cannot be sent between threads safely
  --&gt; src/main.rs:23:5
   |
23 |     is_send(foo());
   |     ^^^^^^^ future returned by `foo()` is not `Send`
   |
note: future is not send because this value is used across an await
NN |     let g = x.lock().unwrap();
   |         - has type `std::sync::MutexGuard&lt;&#39;_, u32&gt;`
NN |     baz().await;
   |           ^^^^^ await occurs here, with `g` maybe used later
NN |  }
   |  - `g` is later dropped here
note: `Send` is required because of this where clause
  --&gt; src/main.rs:5:1
   |
5  | fn is_send&lt;T: Send&gt;(t: T) {
   |            -------
</pre></div>



<a name="176559863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176559863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176559863">(Sep 25 2019 at 12:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> is your branch pushed somewhere I can take a look?</p>



<a name="176559888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176559888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176559888">(Sep 25 2019 at 12:42)</a>:</h4>
<p>Might help me to give an intelligent answer</p>



<a name="176561201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176561201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176561201">(Sep 25 2019 at 12:58)</a>:</h4>
<p>Not yet, can do shortly.</p>



<a name="176561916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176561916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176561916">(Sep 25 2019 at 13:05)</a>:</h4>
<p>woah what is <em>that</em> :)</p>



<a name="176562356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176562356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176562356">(Sep 25 2019 at 13:09)</a>:</h4>
<p>Oops.</p>



<a name="176562423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176562423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176562423">(Sep 25 2019 at 13:10)</a>:</h4>
<p><a href="https://github.com/davidtwco/rust/tree/issue-64130-async-error-definition" target="_blank" title="https://github.com/davidtwco/rust/tree/issue-64130-async-error-definition">https://github.com/davidtwco/rust/tree/issue-64130-async-error-definition</a> - copying and pasting is hard.</p>



<a name="176563349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176563349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176563349">(Sep 25 2019 at 13:20)</a>:</h4>
<p>thanks :)</p>



<a name="176667196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667196">(Sep 26 2019 at 15:17)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> so I'm looking at your branch now -- I think the problem is that you are not getting the <code>HirId</code> of the correct type. I see this:</p>



<a name="176667198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667198">(Sep 26 2019 at 15:18)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">expr_hir_id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tables</span><span class="p">.</span><span class="n">generator_interior_exprs</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">filter_map</span><span class="p">(</span><span class="o">|</span><span class="n">i</span><span class="o">|</span><span class="w"> </span><span class="o">*</span><span class="n">i</span><span class="p">).</span><span class="n">last</span><span class="p">();</span><span class="w"></span>
</pre></div>



<a name="176667247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667247">(Sep 26 2019 at 15:18)</a>:</h4>
<p>but I think what you want to do is to look at the causation chain</p>



<a name="176667262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667262">(Sep 26 2019 at 15:18)</a>:</h4>
<p>Ah, I look at those types for other generator interiors in the chain..?</p>



<a name="176667268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667268">(Sep 26 2019 at 15:18)</a>:</h4>
<p>the <em>actual error</em> should be for some type <code>T</code> which is a part of the generator</p>



<a name="176667273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667273">(Sep 26 2019 at 15:18)</a>:</h4>
<p>not the other generators</p>



<a name="176667292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667292">(Sep 26 2019 at 15:18)</a>:</h4>
<p>the chain should look something like this:</p>
<ul>
<li>some type T, part of</li>
<li>generator interior, part of</li>
<li>generator</li>
</ul>



<a name="176667304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667304">(Sep 26 2019 at 15:19)</a>:</h4>
<p>really the interior should not be part of that, actually</p>



<a name="176667318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667318">(Sep 26 2019 at 15:19)</a>:</h4>
<p>(I guess i'm going to have to teach myself to use <code>*</code> for lists, dang it)</p>



<a name="176667324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667324">(Sep 26 2019 at 15:19)</a>:</h4>
<blockquote>
<p>really the interior should not be part of that, actually</p>
</blockquote>
<p>but I think it is today</p>



<a name="176667346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667346">(Sep 26 2019 at 15:19)</a>:</h4>
<p>so you want to find that type <code>T</code>, and then find its index</p>



<a name="176667351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667351">(Sep 26 2019 at 15:19)</a>:</h4>
<blockquote>
<p>but I think it is today</p>
</blockquote>
<p>It is on the PR.</p>



<a name="176667358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667358">(Sep 26 2019 at 15:19)</a>:</h4>
<p>Where do I get <code>T</code>?</p>



<a name="176667362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667362">(Sep 26 2019 at 15:19)</a>:</h4>
<p>(yeah, that's a bug, but a separate one)</p>



<a name="176667458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667458">(Sep 26 2019 at 15:20)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> let me look at the debug output a bit, it would be the <code>self_ty</code> from the obligation or something</p>



<a name="176667537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667537">(Sep 26 2019 at 15:21)</a>:</h4>
<p>Sure. On the last generator in the chain (which is the only one I'm looking at now), it's the future, IIRC.</p>



<a name="176667689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667689">(Sep 26 2019 at 15:23)</a>:</h4>
<p>to make life easier, maybe we should add the <code>DefId</code> of the generator to the witness type</p>



<a name="176667713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667713">(Sep 26 2019 at 15:23)</a>:</h4>
<p>ah well never mind that hardly matters</p>



<a name="176667840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667840">(Sep 26 2019 at 15:24)</a>:</h4>
<p>ok so the data structures here are sort of annoying</p>



<a name="176667859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667859">(Sep 26 2019 at 15:25)</a>:</h4>
<p>in the example example we have, the type we want is the <code>MutexGuard</code> type, which is part of the initial <code>Obligation</code></p>



<a name="176667880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667880">(Sep 26 2019 at 15:25)</a>:</h4>
<p>unfortunately your function is generic over T so it can't readily extract that :)</p>



<a name="176667887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667887">(Sep 26 2019 at 15:25)</a>:</h4>
<p>though we could add a trait bound for it</p>



<a name="176667909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667909">(Sep 26 2019 at 15:25)</a>:</h4>
<p>or we could make some variant of <code>note_obligation_cause</code> that applies when we have a <code>Obligation&lt;TraitRef&gt;</code> or whatever</p>



<a name="176667979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176667979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176667979">(Sep 26 2019 at 15:26)</a>:</h4>
<p><em>if</em> you have to climb the stack, however, the self-type would come from the <code>parent_trait_ref</code> at each step</p>



<a name="176668062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176668062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176668062">(Sep 26 2019 at 15:27)</a>:</h4>
<p>so right now you have something like</p>
<div class="codehilite"><pre><span></span>Obligation(
    MutexGuard: Send, // &lt;-- what you have to prove, and failed
    DerivedObligation {
        parent_trait_ref: GeneratorWitness(...), // annoying
        parent_cause: DerivedObligation {
            parent_trait_ref: Generator(def_id), // &lt;-- what we see that tells us we are in a generator
            parent_cause: ... // irrelevant
</pre></div>



<a name="176668070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176668070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176668070">(Sep 26 2019 at 15:27)</a>:</h4>
<p>actually adding a <code>DefId</code> to the generator witness might help a little</p>



<a name="176668125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176668125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176668125">(Sep 26 2019 at 15:28)</a>:</h4>
<p>the idea would be "when we see a "cause" that is a DerivedObligation from a  generator witness, we get its def-id, and we take the <em>self type</em> of the current thing we are trying to prove"</p>



<a name="176668150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176668150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176668150">(Sep 26 2019 at 15:28)</a>:</h4>
<p>if we iterate to the next step, we get the self-type from the <code>parent_trait_ref</code> and repeat</p>



<a name="176668169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176668169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176668169">(Sep 26 2019 at 15:28)</a>:</h4>
<p>but even w/o modifying the <code>GeneratorWitness</code> would be possible, just .. hairier</p>



<a name="176668204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176668204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176668204">(Sep 26 2019 at 15:29)</a>:</h4>
<p>does that make sense, <span class="user-mention" data-user-id="116107">@davidtwco</span>? (I'm figuring you'd prefer to make the changes? I probably don't have time anyway, though I'm tempted to tinker with it :P)</p>



<a name="176668219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176668219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176668219">(Sep 26 2019 at 15:29)</a>:</h4>
<p>(but actually today is super full for me)</p>



<a name="176668309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176668309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176668309">(Sep 26 2019 at 15:30)</a>:</h4>
<p>I think so, with that extra context I'll take another look later today.</p>



<a name="176846518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176846518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176846518">(Sep 28 2019 at 23:36)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Sorry for the delay here, updated <a href="https://github.com/davidtwco/rust/tree/issue-64130-async-error-definition" target="_blank" title="https://github.com/davidtwco/rust/tree/issue-64130-async-error-definition">the branch</a>. I'm now getting an error that looks like this:</p>
<div class="codehilite"><pre><span></span>error[E0277]: `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
  --&gt; $DIR/issue-64130-non-send-future-diags.rs:23:5
   |
LL | fn is_send&lt;T: Send&gt;(t: T) {
   | ------------------------- required by `is_send`
...
LL |     is_send(foo());
   |     ^^^^^^^ `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely
   |
   = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard&lt;&#39;_, u32&gt;`
note: future is not send because this value is used across an await
  --&gt; $DIR/issue-64130-non-send-future-diags.rs:13:10
   |
LL | async fn bar(x: &amp;Mutex&lt;u32&gt;) {
   |          ^^^
LL |     let g = x.lock().unwrap();
   |         - has type `std::sync::MutexGuard&lt;&#39;_, u32&gt;`
LL |     baz().await;
   |     ----------- await occurs here, with `g` maybe used later

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
</pre></div>


<p>Almost there, just missing the "is dropped here" part of your sketch. It is regressing one other test (see the blessed changes on the branch, changes an error to a cycle error) which I've not looked into fixing yet.</p>



<a name="176846747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176846747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176846747">(Sep 28 2019 at 23:44)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> a quick look: a diagnostic item should be used instead of a lang item</p>



<a name="176846768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176846768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176846768">(Sep 28 2019 at 23:45)</a>:</h4>
<p>Will look into changing that tomorrow.</p>



<a name="176872416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176872416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176872416">(Sep 29 2019 at 13:40)</a>:</h4>
<p>Opened <a href="https://github.com/rust-lang/rust/issues/64895" target="_blank" title="https://github.com/rust-lang/rust/issues/64895">#64895</a></p>



<a name="176927735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176927735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176927735">(Sep 30 2019 at 12:38)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> that looks pretty awesome! <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="176976895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176976895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176976895">(Sep 30 2019 at 21:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> I left a <a href="https://github.com/rust-lang/rust/pull/64895#pullrequestreview-295262273" target="_blank" title="https://github.com/rust-lang/rust/pull/64895#pullrequestreview-295262273">few nits</a> here -- I see <span class="user-mention" data-user-id="124288">@oli</span> also r+'d it</p>



<a name="176976955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176976955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176976955">(Sep 30 2019 at 21:34)</a>:</h4>
<p>I edited the description to <code>cc</code> the issue, vs "fixing" it</p>



<a name="176979781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176979781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176979781">(Sep 30 2019 at 22:17)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I've updated the PR to resolve your comments.</p>



<a name="176980205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176980205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176980205">(Sep 30 2019 at 22:23)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> <a href="https://github.com/rust-lang/rust/pull/64895#pullrequestreview-295283005" target="_blank" title="https://github.com/rust-lang/rust/pull/64895#pullrequestreview-295283005">wdyt?</a></p>



<a name="176980292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176980292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176980292">(Sep 30 2019 at 22:24)</a>:</h4>
<p>Looks good, will update PR.</p>



<a name="176981192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/176981192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#176981192">(Sep 30 2019 at 22:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> updated again!</p>



<a name="177028221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177028221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177028221">(Oct 01 2019 at 06:49)</a>:</h4>
<p>oh oops, I thought it was waiting for my review</p>



<a name="177131038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177131038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177131038">(Oct 02 2019 at 08:30)</a>:</h4>
<p>Looks like the PR <a href="https://github.com/rust-lang/rust/issues/64964" target="_blank" title="https://github.com/rust-lang/rust/issues/64964">caused an ICE</a></p>



<a name="177147321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177147321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177147321">(Oct 02 2019 at 13:04)</a>:</h4>
<p>d'oh :)</p>



<a name="177147464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177147464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177147464">(Oct 02 2019 at 13:06)</a>:</h4>
<p>ah, I see there's a fix</p>



<a name="177147480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177147480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177147480">(Oct 02 2019 at 13:06)</a>:</h4>
<p>and  it looks quite reasonable, vg</p>



<a name="177147498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177147498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177147498">(Oct 02 2019 at 13:07)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> you had mentioned being up for doing the remaining work, do you have a clear picture of what that is and how to go about it?</p>



<a name="177147825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177147825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177147825">(Oct 02 2019 at 13:10)</a>:</h4>
<p>Was it just intercepting the error earlier (or cancelling it in that function and issuing a new one) with a more specific message?</p>



<a name="177147835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177147835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177147835">(Oct 02 2019 at 13:11)</a>:</h4>
<p>i.e. <a href="https://github.com/rust-lang/rust/pull/64895#discussion_r329794926" target="_blank" title="https://github.com/rust-lang/rust/pull/64895#discussion_r329794926">this comment</a></p>



<a name="177148763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177148763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177148763">(Oct 02 2019 at 13:21)</a>:</h4>
<p>yes</p>



<a name="177148877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177148877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177148877">(Oct 02 2019 at 13:22)</a>:</h4>
<p>ideally we'd produce <a href="https://github.com/rust-lang/rust/issues/64130#issuecomment-534300534" target="_blank" title="https://github.com/rust-lang/rust/issues/64130#issuecomment-534300534">this message</a> --</p>



<a name="177148892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177148892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177148892">(Oct 02 2019 at 13:22)</a>:</h4>
<p>I think there are a few nits, e.g. we'd want to extract the top-most generator frame so we can say things like "future returned by <code>foo()</code>"</p>



<a name="177148965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177148965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177148965">(Oct 02 2019 at 13:23)</a>:</h4>
<p>we may also want to special case "future cannot be sent between threads safely", though I think right now some of that is done via the more generic <code>#[rustc_error]</code> attributes or whatever, maybe we want to extend those with an optional "future" attribute or something?</p>



<a name="177149359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177149359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177149359">(Oct 02 2019 at 13:28)</a>:</h4>
<p>but I'm happy to take incremental steps toward it</p>



<a name="177149452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177149452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177149452">(Oct 02 2019 at 13:28)</a>:</h4>
<blockquote>
<p>I think there are a few nits, e.g. we'd want to extract the top-most generator frame so we can say things like "future returned by <code>foo()</code>"</p>
</blockquote>
<p>I think this and the more-specific error shouldn't be too hard.</p>



<a name="177149484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177149484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177149484">(Oct 02 2019 at 13:29)</a>:</h4>
<p>Right now, the error is pretty general in that it isn't just send that it cares about.</p>



<a name="177151646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177151646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177151646">(Oct 02 2019 at 13:51)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> yep -- and we probably need to consider <code>Sync</code> too --</p>



<a name="177151650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177151650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177151650">(Oct 02 2019 at 13:51)</a>:</h4>
<p>but basically this whole thing is tailored to auto traits</p>



<a name="177151696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177151696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177151696">(Oct 02 2019 at 13:52)</a>:</h4>
<p>(hmm, maybe <code>Clone</code>?)</p>



<a name="177151810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177151810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177151810">(Oct 02 2019 at 13:53)</a>:</h4>
<p>ah, no, of course not, only auto traits, "because <code>impl Trait</code> leakage"</p>



<a name="177151843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177151843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177151843">(Oct 02 2019 at 13:53)</a>:</h4>
<p>it so happens of course that send/sync are a very common case</p>



<a name="177152778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177152778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177152778">(Oct 02 2019 at 14:04)</a>:</h4>
<p>I can make it specialised for those pretty easily I think.</p>



<a name="177164411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177164411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177164411">(Oct 02 2019 at 16:02)</a>:</h4>
<p>(I'm seeing that ICE just on a <code>-i</code> bootstrap, actually)</p>



<a name="177164449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177164449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177164449">(Oct 02 2019 at 16:02)</a>:</h4>
<p>I did too.</p>



<a name="177164456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177164456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177164456">(Oct 02 2019 at 16:02)</a>:</h4>
<p>(this morning, not before it landed)</p>



<a name="177340498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177340498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177340498">(Oct 04 2019 at 13:51)</a>:</h4>
<p>Was the PR meant to fix all instances of <code>&lt;Some type&gt; cannot be sent between threads safely</code> regarding futures? I have one that does not end in a <code>note: required by &lt;X&gt;</code>. I can find out if it's possible for me to share this code (it would be an amazing example of an <em>extremely</em> long type being converted to a nice error message)</p>



<a name="177348260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177348260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177348260">(Oct 04 2019 at 15:10)</a>:</h4>
<p>not necessarily -- but it'd be good to see your example <span class="user-mention" data-user-id="116114">@Paul Faria</span></p>



<a name="177352380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177352380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177352380">(Oct 04 2019 at 15:54)</a>:</h4>
<p>Would just the error suffice or access to the code would help too? I can see if I'm allowed to publish it opensource, it's just a utility tool.</p>



<a name="177361604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177361604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177361604">(Oct 04 2019 at 17:32)</a>:</h4>
<p><span class="user-mention" data-user-id="116114">@Paul Faria</span> the error might suffice</p>



<a name="177368102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177368102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177368102">(Oct 04 2019 at 18:46)</a>:</h4>
<p><a href="https://gist.github.com/Nashenas88/f39c143daf2147d3d599ec78c5f6c961" target="_blank" title="https://gist.github.com/Nashenas88/f39c143daf2147d3d599ec78c5f6c961">https://gist.github.com/Nashenas88/f39c143daf2147d3d599ec78c5f6c961</a> hopefully this helps</p>



<a name="177371956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177371956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177371956">(Oct 04 2019 at 19:35)</a>:</h4>
<p>If I remember from reading <span class="user-mention" data-user-id="116107">@davidtwco</span>'s gist, I thnk we might have been somewhat conservative when the generator appears inside of a struct, does that sound right <span class="user-mention" data-user-id="116107">@davidtwco</span>?</p>



<a name="177371975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177371975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177371975">(Oct 04 2019 at 19:35)</a>:</h4>
<p>If so, I wonder if we should be more general than that</p>



<a name="177371986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177371986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177371986">(Oct 04 2019 at 19:35)</a>:</h4>
<p>(I sort of think so)</p>



<a name="177373290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177373290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177373290">(Oct 04 2019 at 19:49)</a>:</h4>
<p>It only considers cases where the obligation stack is generators, generator interiors, opaque types and <code>std::future::GenFuture</code>.</p>



<a name="177373461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177373461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177373461">(Oct 04 2019 at 19:51)</a>:</h4>
<p>And the last obligation is a item/binding obligation.</p>



<a name="177374499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177374499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177374499">(Oct 04 2019 at 20:04)</a>:</h4>
<blockquote>
<p>It only considers cases where the obligation stack is generators, generator interiors, opaque types and <code>std::future::GenFuture</code>.</p>
</blockquote>
<p>notably, anyone using combinators will be unable to benefit here :(</p>



<a name="177374512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177374512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177374512">(Oct 04 2019 at 20:04)</a>:</h4>
<p>I think we should consider extending that to "random structs" that live "atop" the generators</p>



<a name="177374550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177374550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177374550">(Oct 04 2019 at 20:05)</a>:</h4>
<blockquote>
<p>And the last obligation is a item/binding obligation.</p>
</blockquote>
<p>I'm not sure I understand that</p>



<a name="177374817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177374817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177374817">(Oct 04 2019 at 20:08)</a>:</h4>
<blockquote>
<blockquote>
<p>And the last obligation is a item/binding obligation.</p>
</blockquote>
<p>I'm not sure I understand that</p>
</blockquote>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709">https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709</a></p>



<a name="177478534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177478534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177478534">(Oct 06 2019 at 22:04)</a>:</h4>
<p><strong>Update:</strong> I've got the error changed as shown in the diff below:</p>
<div class="codehilite"><pre><span></span><span class="gh">diff --git a/src/test/ui/async-await/issue-64130-non-send-future-diags.stderr b/src/test/ui/async-await/issue-64130-non-send-future-diags.stderr</span>
<span class="gh">index 9e9fc52e30b..a393669a3ab 100644</span>
<span class="gd">--- a/src/test/ui/async-await/issue-64130-non-send-future-diags.stderr</span>
<span class="gi">+++ b/src/test/ui/async-await/issue-64130-non-send-future-diags.stderr</span>
<span class="gu">@@ -1,14 +1,14 @@</span>
<span class="gd">-error[E0277]: `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely</span>
<span class="gi">+error[E0277]: future cannot be sent between threads safely</span>
   --&gt; $DIR/issue-64130-non-send-future-diags.rs:23:5
    |
 LL | fn is_send&lt;T: Send&gt;(t: T) {
    |    -------    ---- required by this bound in `is_send`
 ...
 LL |     is_send(foo());
<span class="gd">-   |     ^^^^^^^ `std::sync::MutexGuard&lt;&#39;_, u32&gt;` cannot be sent between threads safely</span>
<span class="gi">+   |     ^^^^^^^ future returned by `foo` is not send</span>
    |
    = help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `std::sync::MutexGuard&lt;&#39;_, u32&gt;`
<span class="gd">-note: future does not implement `std::marker::Send` as this value is used across an await</span>
<span class="gi">+note: future is not send as this value is used across an await</span>
   --&gt; $DIR/issue-64130-non-send-future-diags.rs:15:5
    |
 LL |     let g = x.lock().unwrap();
</pre></div>


<p>I've generalized it a bit so that combinators and other cases should use this error too and that there's a specialized version for sync - not written test cases for those yet though. I'm going to polish it off a bit locally before throwing a PR up.</p>



<a name="177478882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177478882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177478882">(Oct 06 2019 at 22:16)</a>:</h4>
<p>"is not send" reads weird.</p>



<a name="177478894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177478894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177478894">(Oct 06 2019 at 22:17)</a>:</h4>
<p>I was just working to <a href="https://github.com/rust-lang/rust/issues/64130#issuecomment-534300534" target="_blank" title="https://github.com/rust-lang/rust/issues/64130#issuecomment-534300534">the draft in this comment</a>, I think it reads fine though? Any suggestions for alternate wording?</p>



<a name="177478941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177478941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177478941">(Oct 06 2019 at 22:18)</a>:</h4>
<blockquote>
<p>I was just working to <a href="https://github.com/rust-lang/rust/issues/64130#issuecomment-534300534" target="_blank" title="https://github.com/rust-lang/rust/issues/64130#issuecomment-534300534">the draft in this comment</a>, I think it reads fine though? Any suggestions for alternate wording?</p>
</blockquote>
<p>is not <code>Send</code>? That capital letter does a lot, and so does the inline code markup</p>



<a name="177478950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177478950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177478950">(Oct 06 2019 at 22:19)</a>:</h4>
<p>I can change it to that.</p>



<a name="177516153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177516153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177516153">(Oct 07 2019 at 12:58)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> looks good to me!</p>



<a name="177516192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177516192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177516192">(Oct 07 2019 at 12:58)</a>:</h4>
<blockquote>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709">https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709</a></p>
</blockquote>
<p>ok ok I see -- i'm not sure if that's relevant to <span class="user-mention" data-user-id="116114">@Paul Faria</span>'s example. It's probably the case that we could lift this restriction if needed.</p>



<a name="177516385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177516385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177516385">(Oct 07 2019 at 13:00)</a>:</h4>
<blockquote>
<blockquote>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709">https://github.com/rust-lang/rust/blob/master/src/librustc/traits/error_reporting.rs#L1708-L1709</a></p>
</blockquote>
<p>ok ok I see -- i'm not sure if that's relevant to <span class="user-mention silent" data-user-id="116114">Paul Faria</span>'s example. It's probably the case that we could lift this restriction if needed.</p>
</blockquote>
<p>I have in my newest changes.</p>



<a name="177715828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177715828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177715828">(Oct 09 2019 at 13:57)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> by any chance, could you try <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2a9dbea32d31457d50d40b99c52ee214" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2a9dbea32d31457d50d40b99c52ee214">this example</a> on your current branch?</p>



<a name="177715838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177715838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177715838">(Oct 09 2019 at 13:57)</a>:</h4>
<p>I'm curious if the diagnostics at least are improved</p>



<a name="177716076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177716076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177716076">(Oct 09 2019 at 13:59)</a>:</h4>
<p>Still the old error, I'll add that as a test case to get working.</p>



<a name="177997812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177997812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177997812">(Oct 12 2019 at 17:12)</a>:</h4>
<p>Just got around to looking at that case now, the diagnostic doesn't trigger for that because <code>wat</code> isn't an <code>async fn</code>, just a <code>fn</code> with an <code>async move { }</code> and for a reason I've yet to understand, this diagnostic will cause a cycle-error for <code>async move { }</code>.</p>



<a name="177998169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177998169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177998169">(Oct 12 2019 at 17:21)</a>:</h4>
<p>I've opened <a href="https://github.com/rust-lang/rust/issues/65345" target="_blank" title="https://github.com/rust-lang/rust/issues/65345">#65345</a> with what I have so far.</p>



<a name="177998187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/177998187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#177998187">(Oct 12 2019 at 17:21)</a>:</h4>
<p>Struggling to make it apply to more cases, it still feels very tied to a handful of specific conditions.</p>



<a name="178428004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178428004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178428004">(Oct 17 2019 at 22:33)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="116107">@davidtwco</span> -- so <a href="https://github.com/rust-lang/rust/pull/65345" target="_blank" title="https://github.com/rust-lang/rust/pull/65345">https://github.com/rust-lang/rust/pull/65345</a> is causing add'l cycle errors?</p>



<a name="178428096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178428096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178428096">(Oct 17 2019 at 22:35)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> No. But, if I remove the check that there must be an <code>async fn</code>, so that it works with <code>async move { }</code> blocks, then <em>that</em> causes cycle errors (for an example, see <a href="#narrow/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130/near/177715828" title="#narrow/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130/near/177715828">the case you sent on Oct 9th</a>).</p>



<a name="178428169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178428169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178428169">(Oct 17 2019 at 22:36)</a>:</h4>
<p>I should clarify, this happens without that patch, the original patch did the same, which is why that check for <code>async fn</code> specifically existed in the first place.</p>



<a name="178428196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178428196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178428196">(Oct 17 2019 at 22:37)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/65345/files#diff-0e12890ad498e250783f40f88a8b8ec6R1824-R1835" target="_blank" title="https://github.com/rust-lang/rust/pull/65345/files#diff-0e12890ad498e250783f40f88a8b8ec6R1824-R1835">These lines specifically</a></p>



<a name="178661566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178661566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178661566">(Oct 21 2019 at 14:41)</a>:</h4>
<p>I read the "Future is not Send" blog post and have a question about the error and diagnostic. If this isn't the right place to ask, please redirect me to the right place.</p>
<p><a href="https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html" target="_blank" title="https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html">https://blog.rust-lang.org/inside-rust/2019/10/11/AsyncAwait-Not-Send-Error-Improvements.html</a></p>
<div class="codehilite"><pre><span></span><span class="n">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">Mutex</span><span class="o">&lt;</span><span class="kt">u32</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">g</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="n">lock</span><span class="p">().</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">baz</span><span class="p">().</span><span class="n">await</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>As NLL is now in use, why does <code>g</code> live until the end of the function? Shouldn't it be dropped once it is no longer used?</p>



<a name="178663689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178663689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178663689">(Oct 21 2019 at 15:03)</a>:</h4>
<p>NLL has little to do with this -- you'd want the lock to still be taken for the duration of the scope</p>



<a name="178663697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178663697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178663697">(Oct 21 2019 at 15:03)</a>:</h4>
<p>i.e. it's not really a lifetimes issue</p>



<a name="178663721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178663721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178663721">(Oct 21 2019 at 15:03)</a>:</h4>
<p>in the <code>'a</code> sense :)</p>



<a name="178672387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178672387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178672387">(Oct 21 2019 at 16:28)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> do you know why this happens? It's probably not specific to locks, so what is the underlying issue? (If you don't know feel free to redirect me)</p>



<a name="178675359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178675359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178675359">(Oct 21 2019 at 17:03)</a>:</h4>
<p><span class="user-mention" data-user-id="218805">@Mark Drobnak</span> So the code example can be rewritten as the following, which illustrates why it would change behavior for g's lifetime to end before the await</p>
<div class="codehilite"><pre><span></span><span class="n">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">Mutex</span><span class="o">&lt;</span><span class="kt">u32</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">g</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="n">lock</span><span class="p">().</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">baz</span><span class="p">().</span><span class="n">await</span><span class="w"></span>
<span class="w">    </span><span class="n">mem</span>::<span class="n">drop</span><span class="p">(</span><span class="n">g</span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="178675385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178675385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178675385">(Oct 21 2019 at 17:03)</a>:</h4>
<p>(since the code in the destructor would then run earlier)</p>



<a name="178676056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178676056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178676056">(Oct 21 2019 at 17:11)</a>:</h4>
<p>Right, but I thought NLL would have changed it to be:</p>
<div class="codehilite"><pre><span></span><span class="n">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">bar</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">Mutex</span><span class="o">&lt;</span><span class="kt">u32</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">g</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="n">lock</span><span class="p">().</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="n">mem</span>::<span class="n">drop</span><span class="p">(</span><span class="n">g</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">baz</span><span class="p">().</span><span class="n">await</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="178676137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178676137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178676137">(Oct 21 2019 at 17:12)</a>:</h4>
<p>What stops this from happening?</p>



<a name="178679824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178679824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178679824">(Oct 21 2019 at 17:49)</a>:</h4>
<p>NLL does not change destructor ordering</p>



<a name="178679834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178679834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178679834">(Oct 21 2019 at 17:49)</a>:</h4>
<p>that would be a massive breaking change</p>



<a name="178679846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178679846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178679846">(Oct 21 2019 at 17:49)</a>:</h4>
<p>like, that drop releases the lock</p>



<a name="178679872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178679872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178679872">(Oct 21 2019 at 17:49)</a>:</h4>
<p>if we previously had that for the entire block and now don't that could have a number of unexpected effects that people don't want</p>



<a name="178681156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178681156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178681156">(Oct 21 2019 at 18:02)</a>:</h4>
<p>Ok, I see. It's a difference between reference and data lifetimes. The data lifetimes didn't change as part of NLL, only references. Thanks for sticking with me to figure this out!</p>



<a name="178681257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178681257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Drobnak <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178681257">(Oct 21 2019 at 18:03)</a>:</h4>
<p>This distinction is talked about in the NLL RFC:</p>
<blockquote>
<p>Note that Rust uses the term lifetime in a very particular way. In everyday speech, the word lifetime can be used in two distinct -- but similar -- ways:</p>
<ol>
<li>The lifetime of a reference, corresponding to the span of time in which that reference is used.</li>
<li>The lifetime of a value, corresponding to the span of time before that value gets freed (or, put another way, before the destructor for the value runs).</li>
</ol>
</blockquote>
<p><a href="https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md" target="_blank" title="https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md">https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md</a></p>



<a name="178947540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178947540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178947540">(Oct 24 2019 at 12:44)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> do you have any thoughts on why the diagnostic improvement causes cycle errors when I allow it to apply to errors originating from <code>async { }</code> (not <code>async fn</code>)?</p>



<a name="178948025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178948025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178948025">(Oct 24 2019 at 12:51)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> I .. do not :) can I see the diff maybe?</p>



<a name="178948042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178948042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178948042">(Oct 24 2019 at 12:51)</a>:</h4>
<p>eddyb might've fixed this in a recent PR</p>



<a name="178948049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178948049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178948049">(Oct 24 2019 at 12:51)</a>:</h4>
<p>not sure though, I recall something similar</p>



<a name="178950073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178950073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178950073">(Oct 24 2019 at 13:15)</a>:</h4>
<p>The diff would be removing <a href="https://github.com/rust-lang/rust/pull/65345/files#diff-0e12890ad498e250783f40f88a8b8ec6R1824-R1835" target="_blank" title="https://github.com/rust-lang/rust/pull/65345/files#diff-0e12890ad498e250783f40f88a8b8ec6R1824-R1835">these lines</a>?</p>



<a name="178950079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178950079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178950079">(Oct 24 2019 at 13:15)</a>:</h4>
<blockquote>
<p>eddyb might've fixed this in a recent PR</p>
</blockquote>
<p>I'll rebase and check.</p>



<a name="178951315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178951315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178951315">(Oct 24 2019 at 13:29)</a>:</h4>
<p>oh I'm not sure it landed... let me look</p>



<a name="178951350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178951350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178951350">(Oct 24 2019 at 13:29)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> I was referring to <a href="https://github.com/rust-lang/rust/pull/65743" target="_blank" title="https://github.com/rust-lang/rust/pull/65743">https://github.com/rust-lang/rust/pull/65743</a></p>



<a name="178951378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178951378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178951378">(Oct 24 2019 at 13:30)</a>:</h4>
<p>not sure if that actually relates or not though</p>



<a name="178951433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178951433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178951433">(Oct 24 2019 at 13:30)</a>:</h4>
<p>It wouldn't take much to rebase atop and check, thanks!</p>



<a name="178954445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178954445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178954445">(Oct 24 2019 at 14:01)</a>:</h4>
<p>Unfortunately, that didn't do the trick.</p>



<a name="178954450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178954450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178954450">(Oct 24 2019 at 14:01)</a>:</h4>
<p>Still cycle errors.</p>



<a name="178956303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/178956303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#178956303">(Oct 24 2019 at 14:17)</a>:</h4>
<p>This is an example of one of the cycle errors:</p>
<div class="codehilite"><pre><span></span>error[E0391]: cycle detected when processing `main`
  --&gt; /home/david/projects/rust/rust4/src/test/ui/generator/not-send-sync.rs:5:1
   |
LL | fn main() {
   | ^^^^^^^^^
   |
note: ...which requires processing `main::{{closure}}#1`...
  --&gt; /home/david/projects/rust/rust4/src/test/ui/generator/not-send-sync.rs:16:17
   |
LL |     assert_send(|| {
   |                 ^^
   = note: ...which again requires processing `main`, completing the cycle
note: cycle used when processing `main::{{closure}}#0`
  --&gt; /home/david/projects/rust/rust4/src/test/ui/generator/not-send-sync.rs:9:17
   |
LL |     assert_sync(|| {
   |                 ^^

error: aborting due to previous error
</pre></div>



<a name="179077349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179077349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179077349">(Oct 25 2019 at 18:37)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> well I guess the problem is <em>somehow</em> related to invoking <code>typeck_tables_of</code> on the generator</p>



<a name="179077376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179077376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179077376">(Oct 25 2019 at 18:38)</a>:</h4>
<p>what's the example?</p>



<a name="179077434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179077434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179077434">(Oct 25 2019 at 18:38)</a>:</h4>
<p>I am guessing that there is some error using the generator</p>



<a name="179077443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179077443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179077443">(Oct 25 2019 at 18:38)</a>:</h4>
<p>triggered by the context that also <em>created</em> the generator</p>



<a name="179077450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179077450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179077450">(Oct 25 2019 at 18:38)</a>:</h4>
<p>and hence we are reporting the error while type-checking that context</p>



<a name="179077459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179077459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179077459">(Oct 25 2019 at 18:38)</a>:</h4>
<p>and so there is a sort of cycle</p>



<a name="179077484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179077484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179077484">(Oct 25 2019 at 18:39)</a>:</h4>
<p>that said, I would expect it may be possible to trigger the error even without removing those lines?</p>



<a name="179077493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179077493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179077493">(Oct 25 2019 at 18:39)</a>:</h4>
<p>but maybe there's some reason you can't</p>



<a name="179080215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179080215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179080215">(Oct 25 2019 at 19:14)</a>:</h4>
<p>That example was from the not-send-sync test.</p>



<a name="179080241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179080241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179080241">(Oct 25 2019 at 19:14)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="116107">davidtwco</span> by any chance, could you try <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2a9dbea32d31457d50d40b99c52ee214" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2a9dbea32d31457d50d40b99c52ee214">this example</a> on your current branch?</p>
</blockquote>
<p>This case also triggers it.</p>



<a name="179081054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179081054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179081054">(Oct 25 2019 at 19:27)</a>:</h4>
<p>I think because I rely on the information I put in the typeck table to generate the error, as soon as I get rid of that check, and it gets to that point, it cycle errors. I just don’t know how to get around that.</p>



<a name="179428125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428125">(Oct 30 2019 at 12:58)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> so I have to apply a diff to see the cycle errors?</p>



<a name="179428137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428137">(Oct 30 2019 at 12:58)</a>:</h4>
<p>Yeah.</p>



<a name="179428159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428159">(Oct 30 2019 at 12:59)</a>:</h4>
<p>The PR currently passes everything by prohibiting the diagnostic from applying to non-<code>async fn</code> cases.</p>



<a name="179428174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428174">(Oct 30 2019 at 12:59)</a>:</h4>
<p>Same as the original PR.</p>



<a name="179428212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428212">(Oct 30 2019 at 12:59)</a>:</h4>
<p>ok I see</p>



<a name="179428225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428225">(Oct 30 2019 at 12:59)</a>:</h4>
<p>I commented out the <a href="https://github.com/rust-lang/rust/pull/65345/files#diff-0e12890ad498e250783f40f88a8b8ec6R1824-R1835" target="_blank" title="https://github.com/rust-lang/rust/pull/65345/files#diff-0e12890ad498e250783f40f88a8b8ec6R1824-R1835">lines you mentioned earlier</a></p>



<a name="179428228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428228">(Oct 30 2019 at 12:59)</a>:</h4>
<p>I'm doing a build</p>



<a name="179428309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428309">(Oct 30 2019 at 13:00)</a>:</h4>
<p>that said, I think I know what the problem is</p>



<a name="179428678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428678">(Oct 30 2019 at 13:04)</a>:</h4>
<p>what I'm <em>not</em> sure of is the best way to fix it</p>



<a name="179428737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179428737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179428737">(Oct 30 2019 at 13:05)</a>:</h4>
<p>ah, hmm</p>



<a name="179429875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179429875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179429875">(Oct 30 2019 at 13:17)</a>:</h4>
<p>So I'm trying something <span class="user-mention" data-user-id="116107">@davidtwco</span> -- which is to get the typeck-tables optionally from the current <code>InferCtxt</code></p>



<a name="179429975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179429975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179429975">(Oct 30 2019 at 13:18)</a>:</h4>
<p>but hmm that doesn't <em>quite</em> help</p>



<a name="179429985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179429985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179429985">(Oct 30 2019 at 13:18)</a>:</h4>
<p>oh, I bet I know why</p>



<a name="179431152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431152">(Oct 30 2019 at 13:30)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> ok I pushed a commit</p>



<a name="179431163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431163">(Oct 30 2019 at 13:30)</a>:</h4>
<p>it's marked as <code>[wip]</code></p>



<a name="179431169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431169">(Oct 30 2019 at 13:30)</a>:</h4>
<p>here's the good news: no more cycle errors</p>



<a name="179431174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431174">(Oct 30 2019 at 13:30)</a>:</h4>
<p>the bad news is: the nice diagnostic doesn't trigger</p>



<a name="179431213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431213">(Oct 30 2019 at 13:30)</a>:</h4>
<p>I have to run for a bit but my <em>guess</em> here is that the "in-progress tables" haven't had the generator information added to them yet?</p>



<a name="179431257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431257">(Oct 30 2019 at 13:31)</a>:</h4>
<p>otoh, I thought that we added that information at the same time as we resolved the inference variables, so that could be just wrong</p>



<a name="179431363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431363">(Oct 30 2019 at 13:32)</a>:</h4>
<blockquote>
<p>here's the good news: no more cycle errors</p>
</blockquote>
<p>I'm like 90% sure this fix is sufficient -- I was a bit afraid you might have</p>
<ul>
<li>function X</li>
<li>requires function Y</li>
<li>requires function X</li>
</ul>
<p>so that the in-progress tables are not the same as the "current function" being tested, but I think that you can't actually wind up here in that case, because you can't have a generator type with the def-id</p>



<a name="179431375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431375">(Oct 30 2019 at 13:32)</a>:</h4>
<p>/me -&gt; out</p>



<a name="179431718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179431718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179431718">(Oct 30 2019 at 13:36)</a>:</h4>
<p>Thanks! Will take a look why it doesn't trigger now.</p>



<a name="179433579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179433579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179433579">(Oct 30 2019 at 13:54)</a>:</h4>
<p>For <code>not-send-sync</code>, I get </p>
<div class="codehilite"><pre><span></span>error[E0277]: `std::cell::Cell&lt;i32&gt;` cannot be shared between threads safely
  --&gt; src/test/ui/generator/not-send-sync.rs:16:5
   |
7  |     fn assert_send&lt;T: Send&gt;(_: T) {}
   |        -----------    ---- required by this bound in `main::assert_send`
...
16 |     assert_send(|| {
   |     ^^^^^^^^^^^ `std::cell::Cell&lt;i32&gt;` cannot be shared between threads safely
   |
   = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell&lt;i32&gt;`
   = note: required because of the requirements on the impl of `std::marker::Send` for `&amp;std::cell::Cell&lt;i32&gt;`
   = note: required because it appears within the type `[generator@src/test/ui/generator/not-send-sync.rs:16:17: 20:6 a:&amp;std::cell::Cell&lt;i32&gt; _]`

error: future cannot be shared between threads safely
  --&gt; src/test/ui/generator/not-send-sync.rs:9:5
   |
6  |     fn assert_sync&lt;T: Sync&gt;(_: T) {}
   |        -----------    ---- required by this bound in `main::assert_sync`
...
9  |     assert_sync(|| {
   |     ^^^^^^^^^^^ future returned by `main` is not `Sync`
   |
   = help: within `[generator@src/test/ui/generator/not-send-sync.rs:9:17: 13:6 {std::cell::Cell&lt;i32&gt;, ()}]`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell&lt;i32&gt;`
note: future is not `Sync` as this value is used across an await
  --&gt; src/test/ui/generator/not-send-sync.rs:12:9
   |
11 |         let a = Cell::new(2);
   |             - has type `std::cell::Cell&lt;i32&gt;`
12 |         yield;
   |         ^^^^^ await occurs here, with `a` maybe used later
13 |     });
   |     - `a` is later dropped here

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
</pre></div>


<p>I think that's correct, <code>assert_send</code> doesn't have any variables inside the generator that aren't <code>Send</code>, it's only the captured var from <em>outside</em> the generator.</p>



<a name="179433623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179433623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179433623">(Oct 30 2019 at 13:54)</a>:</h4>
<p>I'll need to adjust the wording so if it isn't async then we say "yield" instead of "await".</p>



<a name="179434550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179434550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179434550">(Oct 30 2019 at 14:03)</a>:</h4>
<blockquote>
<p>by any chance, could you try <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2a9dbea32d31457d50d40b99c52ee214" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2a9dbea32d31457d50d40b99c52ee214">this example</a> on your current branch?</p>
</blockquote>
<p>this is the example I was saying doesn't trigger, I think</p>



<a name="179434835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179434835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179434835">(Oct 30 2019 at 14:05)</a>:</h4>
<p>Oh, I'll check that in a moment then.</p>



<a name="179437214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179437214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179437214">(Oct 30 2019 at 14:28)</a>:</h4>
<p>The issue with that case is that the type in the obligation is <code>dyn Any + Send + 'static</code> but the generator interior list doesn't contain that, it does contain a <code>Client</code> (whose only field is the type we're looking for).</p>



<a name="179437348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179437348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179437348">(Oct 30 2019 at 14:29)</a>:</h4>
<p>So I suppose I need to check if the generator interior type "contains" the target type.</p>



<a name="179439078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179439078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179439078">(Oct 30 2019 at 14:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> what I expected to do was to take the type from the frame "just below" the generator in the "backtrace"</p>



<a name="179449503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179449503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179449503">(Oct 30 2019 at 16:18)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Current issue: checking two <code>&amp;Client</code> types (from that test case) for equality returns <code>false</code>, I assume that the region is different in the type, what function do I use to normalize for that?</p>



<a name="179449583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179449583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179449583">(Oct 30 2019 at 16:19)</a>:</h4>
<p>Was previously just checking <code>TyS::same_type</code>.</p>



<a name="179451522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179451522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179451522">(Oct 30 2019 at 16:40)</a>:</h4>
<p>(I've worked around it with a <code>builtin_deref</code>)</p>



<a name="179454469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/179454469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#179454469">(Oct 30 2019 at 17:12)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/65345#pullrequestreview-309376822" target="_blank" title="https://github.com/rust-lang/rust/pull/65345#pullrequestreview-309376822">Updated the PR</a> with my changes, left some comments where the diagnostic could get better or where I did a hack.</p>



<a name="183110408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183110408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183110408">(Dec 10 2019 at 22:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> ok I'm going to pull this locally I guess</p>



<a name="183170420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183170420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183170420">(Dec 11 2019 at 15:53)</a>:</h4>
<p>ok I'm getting to this now, moving slower than I would like</p>



<a name="183170468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183170468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183170468">(Dec 11 2019 at 15:54)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> are you around at all ?</p>



<a name="183170497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183170497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183170497">(Dec 11 2019 at 15:54)</a>:</h4>
<p>I’m here</p>



<a name="183171945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183171945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183171945">(Dec 11 2019 at 16:07)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> reviewing the PR, I guess the thing you were least comfortable with was the use of <code>target_ty.builtin_deref</code>, right?</p>



<a name="183171952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183171952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183171952">(Dec 11 2019 at 16:07)</a>:</h4>
<p>That does feel a bit ad-hoc</p>



<a name="183171963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183171963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183171963">(Dec 11 2019 at 16:07)</a>:</h4>
<p>Yeah.</p>



<a name="183172041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172041">(Dec 11 2019 at 16:08)</a>:</h4>
<p>It also failed for an example I checked at a previously weekly meeting, IIRC.</p>



<a name="183172044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172044">(Dec 11 2019 at 16:08)</a>:</h4>
<p>I am wondering if it's connected to <a href="https://github.com/rust-lang/rust/pull/65345#discussion_r337709167" target="_blank" title="https://github.com/rust-lang/rust/pull/65345#discussion_r337709167">my comment here</a> about just taking the last span in the table</p>



<a name="183172051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172051">(Dec 11 2019 at 16:08)</a>:</h4>
<p>i.e., it feels like there's something missing to me,</p>



<a name="183172059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172059">(Dec 11 2019 at 16:08)</a>:</h4>
<p>of knowing precisely what type/variable you are looking for</p>



<a name="183172075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172075">(Dec 11 2019 at 16:08)</a>:</h4>
<p>I guess I will re-read a bit to try and see if I can be more specific</p>



<a name="183172372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172372">(Dec 11 2019 at 16:11)</a>:</h4>
<p>If I remember correctly, the primary reason that <code>TyS::same_type</code> would return <code>false</code> was the <code>Region</code> in a <code>ty::Ref(..)</code>, which is why I went with that approach.</p>



<a name="183172429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172429">(Dec 11 2019 at 16:12)</a>:</h4>
<p>Though I feel like there was another case that the current code didn’t handle but we expected it to.</p>



<a name="183172452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172452">(Dec 11 2019 at 16:12)</a>:</h4>
<p>It was one of the examples you asked me to try in a recent weekly meeting.</p>



<a name="183172922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172922">(Dec 11 2019 at 16:16)</a>:</h4>
<p>I guess <span class="user-mention" data-user-id="116107">@davidtwco</span> maybe the easiest way for me to dig is to build a version without the calls to <code>builtin_deref</code> and compare the behavior..? I guess just removing those lines would be what we "expect"?</p>



<a name="183172958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183172958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183172958">(Dec 11 2019 at 16:17)</a>:</h4>
<p>i.e., instead of <code>let ty = ty.builtin_deref().unwrap_or(ty);</code> just .. nothing?</p>



<a name="183173001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173001">(Dec 11 2019 at 16:18)</a>:</h4>
<p>Return the result of <code>TyS::same_type</code> in the <code>find</code> closure.</p>



<a name="183173048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173048">(Dec 11 2019 at 16:18)</a>:</h4>
<p>That will make a test result change.</p>



<a name="183173063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173063">(Dec 11 2019 at 16:18)</a>:</h4>
<p>iow this</p>



<a name="183173069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173069">(Dec 11 2019 at 16:18)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">target_span</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tables</span><span class="p">.</span><span class="n">generator_interior_types</span><span class="p">.</span><span class="n">iter</span><span class="p">()</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">find</span><span class="p">(</span><span class="o">|</span><span class="n">ty</span>::<span class="n">GeneratorInteriorTypeCause</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">ty</span><span class="p">,</span><span class="w"> </span><span class="p">..</span><span class="w"> </span><span class="p">}</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="c1">//let ty = ty.builtin_deref(false).map(|ty_and_mut| ty_and_mut.ty).unwrap_or(ty);</span>
<span class="w">                </span><span class="c1">//let target_ty = target_ty.builtin_deref(false)</span>
<span class="w">                </span><span class="c1">//    .map(|ty_and_mut| ty_and_mut.ty)</span>
<span class="w">                </span><span class="c1">//    .unwrap_or(target_ty);</span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">eq</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ty</span>::<span class="n">TyS</span>::<span class="n">same_type</span><span class="p">(</span><span class="n">ty</span><span class="p">,</span><span class="w"> </span><span class="n">target_ty</span><span class="p">);</span><span class="w"></span>
<span class="w">                </span><span class="n">debug</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;maybe_note_obligation_cause_for_async_await: ty={:?} \</span>
<span class="s">                        target_ty={:?} eq={:?}&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">ty</span><span class="p">,</span><span class="w"> </span><span class="n">target_ty</span><span class="p">,</span><span class="w"> </span><span class="n">eq</span><span class="p">);</span><span class="w"></span>
<span class="w">                </span><span class="n">eq</span><span class="w"></span>
<span class="w">            </span><span class="p">})</span><span class="w"></span>
</pre></div>



<a name="183173091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173091">(Dec 11 2019 at 16:18)</a>:</h4>
<p>That’s what I’d expect.</p>



<a name="183173119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173119">(Dec 11 2019 at 16:18)</a>:</h4>
<p>Some tests <em>should</em> stop passing.</p>



<a name="183173132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173132">(Dec 11 2019 at 16:19)</a>:</h4>
<p>If I remember everything correctly.</p>



<a name="183173141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173141">(Dec 11 2019 at 16:19)</a>:</h4>
<p>ok I'm giving that a try</p>



<a name="183173159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173159">(Dec 11 2019 at 16:19)</a>:</h4>
<p>(we might want to just "erase regions" when doing the comparison, potentially, as an alternative)</p>



<a name="183173263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173263">(Dec 11 2019 at 16:20)</a>:</h4>
<p>That’s what I tried to find before landing on that solution.</p>



<a name="183173487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173487">(Dec 11 2019 at 16:22)</a>:</h4>
<p>do you remember btw why taking the "last" await-span makes sense?</p>
<p>i.e., this line</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">await_span</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tables</span><span class="p">.</span><span class="n">generator_interior_types</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="n">i</span><span class="o">|</span><span class="w"> </span><span class="n">i</span><span class="p">.</span><span class="n">span</span><span class="p">).</span><span class="n">last</span><span class="p">().</span><span class="n">unwrap</span><span class="p">();</span><span class="w"></span>
</pre></div>



<a name="183173556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173556">(Dec 11 2019 at 16:23)</a>:</h4>
<p>I suspect that I would have looked at the generator interior types and found one which was what I wanted.</p>



<a name="183173589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173589">(Dec 11 2019 at 16:23)</a>:</h4>
<p>I feel like what I expet is</p>



<a name="183173593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173593">(Dec 11 2019 at 16:23)</a>:</h4>
<p>we find the index of a type within that list</p>



<a name="183173598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173598">(Dec 11 2019 at 16:24)</a>:</h4>
<p>I probably printed a note with each of them and found that the last was what I wanted.</p>



<a name="183173642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173642">(Dec 11 2019 at 16:24)</a>:</h4>
<p>and then we just re-use it later to find the span</p>



<a name="183173750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173750">(Dec 11 2019 at 16:25)</a>:</h4>
<p>however</p>



<a name="183173760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173760">(Dec 11 2019 at 16:25)</a>:</h4>
<p>maybe the dta structure doesn't quite store what I expect</p>



<a name="183173786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173786">(Dec 11 2019 at 16:25)</a>:</h4>
<p>Unfortunately it’s been a while so I don’t quite remember.</p>



<a name="183173793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173793">(Dec 11 2019 at 16:25)</a>:</h4>
<p>I think I expected to have a <code>await_span</code> such that, for each type in the list, we also tracked some await (or yield) that caused us to include it</p>



<a name="183173796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183173796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183173796">(Dec 11 2019 at 16:25)</a>:</h4>
<p>that's ok</p>



<a name="183179479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179479">(Dec 11 2019 at 17:23)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> so I reproduced the problem, I'm trying a patch that uses <code>erase_regions</code>, which I imagine will work. It seems like the regions that appear in the interior types are generally naming the bound region from the generator, and hence not equal to anything else.</p>



<a name="183179561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179561">(Dec 11 2019 at 17:24)</a>:</h4>
<p>Awesome.</p>



<a name="183179563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179563">(Dec 11 2019 at 17:24)</a>:</h4>
<p>I wonder if that would effect the example you were talking about that didn't work</p>



<a name="183179573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179573">(Dec 11 2019 at 17:24)</a>:</h4>
<p>I would easily imagine it doing so</p>



<a name="183179579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179579">(Dec 11 2019 at 17:24)</a>:</h4>
<p>I wasn’t able to find it.</p>



<a name="183179589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179589">(Dec 11 2019 at 17:24)</a>:</h4>
<p>The current "built-in deref" would only work for the simple case of <code>&amp;A</code> vs <code>&amp;B</code></p>



<a name="183179594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179594">(Dec 11 2019 at 17:24)</a>:</h4>
<p>But it might just have been misremembering.</p>



<a name="183179598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179598">(Dec 11 2019 at 17:24)</a>:</h4>
<p>but not e.g. <code>&amp;&amp;A</code> or <code>&amp;Foo&lt;'x&gt;</code></p>



<a name="183179620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179620">(Dec 11 2019 at 17:25)</a>:</h4>
<p>Yeah, that’s why I didn’t like it.</p>



<a name="183179621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179621">(Dec 11 2019 at 17:25)</a>:</h4>
<p>so for more complex examples it might well be that erasing all regions helps</p>



<a name="183179692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179692">(Dec 11 2019 at 17:25)</a>:</h4>
<p>I suspect the example that I’m thinking of is the one that spurred on the builtin deref solution.</p>



<a name="183179756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183179756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183179756">(Dec 11 2019 at 17:26)</a>:</h4>
<p>It’ll have been in the tests that are in the PR.</p>



<a name="183180760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183180760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183180760">(Dec 11 2019 at 17:36)</a>:</h4>
<p>(I thought <a href="https://github.com/rust-lang/rust/issues/66444" target="_blank" title="https://github.com/rust-lang/rust/issues/66444">https://github.com/rust-lang/rust/issues/66444</a> was the example where it didn't work ?)</p>



<a name="183180818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183180818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183180818">(Dec 11 2019 at 17:37)</a>:</h4>
<p>Oh, could be!</p>



<a name="183180929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183180929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183180929">(Dec 11 2019 at 17:38)</a>:</h4>
<p>I wonder if I confirmed my comment at the time.</p>



<a name="183182004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183182004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183182004">(Dec 11 2019 at 17:50)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> ok, so, "erase types" didn't work, will need to do something a bit more involved (sigh)</p>



<a name="183182021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183182021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183182021">(Dec 11 2019 at 17:51)</a>:</h4>
<p>the problem is that "bound regions" are not erased</p>



<a name="183182042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183182042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183182042">(Dec 11 2019 at 17:51)</a>:</h4>
<p>but there is a longer incantation we can do</p>



<a name="183184555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183184555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183184555">(Dec 11 2019 at 18:16)</a>:</h4>
<p>ok, my more involved patch works</p>



<a name="183184586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183184586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183184586">(Dec 11 2019 at 18:17)</a>:</h4>
<blockquote>
<p>I think I expected to have a <code>await_span</code> such that, for each type in the list, we also tracked some await (or yield) that caused us to include it</p>
</blockquote>
<p>I'm going to ignore this part as it's pre-existing, but I still think the setup could be improved</p>



<a name="183185262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183185262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183185262">(Dec 11 2019 at 18:24)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span> commits pushed</p>



<a name="183185282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183185282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183185282">(Dec 11 2019 at 18:24)</a>:</h4>
<p>I guess I will r+..? seems clear this PR will help</p>



<a name="183185328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183185328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183185328">(Dec 11 2019 at 18:24)</a>:</h4>
<p>Sure, probably makes sense to address anything else in a follow-up rather than having this PR hang around forever.</p>



<a name="183656683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183656683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183656683">(Dec 17 2019 at 15:08)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="116107">@davidtwco</span>, do you think you'd have a chance to review <a href="https://github.com/rust-lang/rust/pull/67116" target="_blank" title="https://github.com/rust-lang/rust/pull/67116">https://github.com/rust-lang/rust/pull/67116</a> ?</p>



<a name="183656973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183656973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183656973">(Dec 17 2019 at 15:11)</a>:</h4>
<p>I'll take a look.</p>



<a name="183658408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183658408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183658408">(Dec 17 2019 at 15:26)</a>:</h4>
<p>(I left some comments, actually)</p>



<a name="183659558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/future-not-send%20diagnostic%20%2364130/near/183659558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/future-not-send.20diagnostic.20.2364130.html#183659558">(Dec 17 2019 at 15:37)</a>:</h4>
<p>Left mine too.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>